package CharacterString;

import java.util.Scanner;

public class userRegister {
    public static void main(String[] args) {
        //定义一个用户名和密码；
        String rightUsername = "xiaolin";
        String rightPassword = "123456";
        //键盘录入；

        Scanner sc = new Scanner(System.in);
        System.out.println("请输入用户名：");
        String username = sc.next();
        System.out.println("请输入密码：");
        String password = sc.next();
        //比较；

        if (username.equals(rightUsername) && password.equals(rightPassword)) {
            System.out.println("用户登录成功；");
        } else {
            //机会；
            for (int i = 0; i < 3; i++) {
                if (i < 2 ) {
                    System.out.println("用户登录失败，用户名或密码错误，您还剩下" + (2 - i) + "次机会；");
                    System.out.println("请重新输入用户名：");
                    username = sc.next();
                    System.out.println("请重新输入密码：");
                    password = sc.next();
                    if (username.equals(rightUsername) && password.equals(rightPassword)) {
                        System.out.println("用户登录成功；");
                        break;
                    }

                } else {
                    System.out.println("账号" +" ' "+username +" ' "+ "被锁定五分钟！");
                }
            }
        }

    }
}
